package com.xyt.imei.core.auth;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.luminary.common.framework.core.auth.RoleProvider;
import com.xyt.imei.core.model.po.User;
import com.xyt.imei.core.util.TokenUtil;

@Component
public class RoleProviderImpl implements RoleProvider<Integer> {

	@Autowired
	private TokenUtil tokenUtil;
	
	@Override
	public List<Integer> getRoleDetails(String token) {
		User user = tokenUtil.getUser();
		if(user != null)
			return Arrays.asList(user.getRole());
		return Collections.<Integer>emptyList();
	}

}
